import 'dart:convert';
import 'dart:io';

const filename = 'std/async/stream/file.dart';

void read() {
  var config = File(filename);
  Stream<List<int>> inputStream = config.openRead();

  inputStream.transform(utf8.decoder).transform(LineSplitter()).listen(
      (String line) {
    print('Got ${line.length.toString().padLeft(2, '0')} $line');
  }, onDone: () {
    print('file is now closed');
  }, onError: (e) {
    print(e);
  });
}

Future<void> s() async {
  var file = File(filename);
  var lines = utf8.decoder.bind(file.openRead()).transform(LineSplitter());
  await for (var line in lines) {
    if (!line.startsWith('//')) print(line);
  }
}

void main(List<String> args) async {
  read();
}
